//
//  JigSawCountDownView.m
//  JigSawKiosk
//
//  Created by Stulberg on 10-10-20.
//  Copyright 2010 FruitonLabs. All rights reserved.
//

#import "JigSawCountDownView.h"


@implementation JigSawCountDownView

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
		[self setupLayers] ;
    }
    return self;
}

- (void)drawRect:(NSRect)dirtyRect {
    // Drawing code here.
}


-(void) setupLayers {
	
	rootLayer = [CALayer layer] ;
	//rootLayer.backgroundColor = CGColorGetConstantColor(kCGColorWhite) ;
	rootLayer.bounds = CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height) ;
	[self setLayer:rootLayer] ;
	
	// record count Down
	float fontSize = [rootLayer bounds].size.height ;
	
	countDownLayer = [CATextLayer layer] ;
	countDownLayer.string = @"" ;
	countDownLayer.font = @"Arial";
	countDownLayer.fontSize = fontSize ;
	countDownLayer.foregroundColor =  CGColorCreateGenericGray(0.6, 1.0) ; 
	countDownLayer.frame = [rootLayer bounds] ;
	[rootLayer addSublayer:countDownLayer] ;
}

-(void) setText:(NSString*)value {
	[CATransaction begin];
	[CATransaction setValue:[NSNumber numberWithFloat: 0.5] forKey:
	 kCATransactionAnimationDuration];
	[CATransaction setValue:[NSNumber numberWithBool: NO] forKey:
	 kCATransactionDisableActions];
	
	countDownLayer.string = value ;
	
	[CATransaction commit];
		
}

@end
